<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    *{
      padding: 0;
      margin: 0;
    }
    main{
      height: 2000px;
      background: darkgoldenrod;
      
    }
    div{
    }
    footer{
      background: #000;
      height: 200px;
      width: 100%;
      position: relative;

    }
    .dongqilai{
      animation-name: dongqilai;
      animation-duration: 2s;
      display: block;
      animation-fill-mode: forwards;
    }
    @keyframes dongqilai{
      0%{
        transform: translateY(200px);
      }
      100%{
        transform: translateY(0px);
      }
    }
    section{
      height: 200px;
      background: darkcyan;
      position: relative;
      z-index: -1;
      display: none;
      transform: translateY(200px);
    }
  </style>
</head>
<body>
  <div>
    <main></main>
    <section></section>
  </div>
  <footer></footer>
  <script>
    // 获取滚动条到浏览器顶部的间距
    function getScrollTop() {  
        var scrollPos;  
        if (window.pageYOffset) {  
        scrollPos = window.pageYOffset; }  
        else if (document.compatMode && document.compatMode != 'BackCompat')  
        { scrollPos = document.documentElement.scrollTop; }  
        else if (document.body) { scrollPos = document.body.scrollTop; }   
        return scrollPos;   
}

    document.querySelector('footer').onclick = function(){
      // 添加动画class
      document.querySelector('section').classList.add('dongqilai')
      // 将滚动条位置 添加上 新出现的section的高度
      document.documentElement.scrollTop = getScrollTop() + 200

    }
  </script>
</body>
</html>